<% omit_columns = {} if omit_columns.nil? %>
<% omit_logo = false if omit_logo.nil? %>
<% omit_comments = false if omit_comments.nil? %>
<% omit_popup = false if omit_popup.nil? %>
<h3><%= h group.name %></h3>
<table class='class_table'>
  <tr class='table_head'>
    <%= content_tag :th, "Pos", :class => "pos" unless omit_columns[:Pos] %>
    <%= content_tag :th, "Name", :class => "name" unless omit_columns[:Name] %>
    <%= content_tag :th, "Pts" unless omit_columns[:Pts] %>
    <%= content_tag :th, "G" unless omit_columns[:G] %>
    <%= content_tag :th, "W" unless omit_columns[:W] %>
    <%= content_tag :th, "D" unless omit_columns[:D] %>
    <%= content_tag :th, "L" unless omit_columns[:L] %>
    <%= content_tag :th, "GF" unless omit_columns[:GF] %>
    <%= content_tag :th, "GA" unless omit_columns[:GA] %>
    <%= content_tag :th, "GD" unless omit_columns[:GD] %>
  </tr>
  <% pos = 0 %>
  <% notes = Array.new %>
  <% team_table.each do |t|
    team = t[0].team
    stats = t[1]
    note_number = ""
    unless omit_comments
      if t[0].comment
        notes.push t[0].comment
        note_number = " (#{notes.size})"
      end
    end
    pos += 1
    tr_class = 'table_line'
    tr_class = 'relegated' if group.is_relegated?(pos)
    tr_class = 'promoted' if group.is_promoted?(pos)
    image_logo = ""
    unless omit_logo
      image_logo = image_tag("logos/" +
                             team.small_logo,
                             :width => 15,
                             :height => 15)
    end
    title_popup = ""
    unless omit_popup
      last_game = stats.last_game
      next_game = stats.next_game
      header_body = ""
      unless last_game.nil?
        header_body << sprintf("%02d", last_game.date.day) << "/"
        header_body << sprintf("%02d", last_game.date.month) << " "
        header_body << last_game.home.name << " "
        header_body << last_game.home_score.to_s << " x "
        header_body << last_game.away_score.to_s << " "
        header_body << last_game.away.name << "<br/>"
      end
      unless next_game.nil?
        header_body << sprintf("%02d", next_game.date.day) << "/"
        header_body << sprintf("%02d", next_game.date.month) << " "
        header_body << next_game.home.name << " x "
        header_body << next_game.away.name << "<br/>"
      end
      title_popup = "header=[] body=[#{header_body}] cssbody=[popupbody]"
    end
  %>
  <tr class='<%= tr_class %>'>
         <%= content_tag :td, pos, :class => "pos" unless omit_columns[:Pos] %>
         <%= content_tag(:td,
                         image_logo +
                         link_to(team.name, :action => 'team',
                                            :id => @championship,
                                            :team => team) +
                         note_number,
                         :class => "name",
                         :title => title_popup) unless omit_columns[:Name] %>
                         
         <%= content_tag :td, stats.points unless omit_columns[:Pts] %>
         <%= content_tag :td, stats.games unless omit_columns[:G] %>
         <%= content_tag :td, stats.wins unless omit_columns[:W] %>
         <%= content_tag :td, stats.draws unless omit_columns[:D] %>
         <%= content_tag :td, stats.losses unless omit_columns[:L] %>
         <%= content_tag :td, stats.goals_for unless omit_columns[:GF] %>
         <%= content_tag :td, stats.goals_against unless omit_columns[:GA] %>
         <%= content_tag :td, stats.goals_diff unless omit_columns[:GD] %>
       </tr>
     <% end %>
   </table>
   <% count = 0 %>
   <% notes.each do |n| %>
     <% count += 1 %>
     <%= "(#{count}) #{n}" %><br/>
   <% end %>
